package cn.iocoder.yudao.module.eval.dal.mysql.subject;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.eval.controller.admin.subject.vo.EvalSubjectPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.subject.EvalSubjectDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 评价科目 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalSubjectMapper extends BaseMapperX<EvalSubjectDO> {

    default PageResult<EvalSubjectDO> selectPage(EvalSubjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalSubjectDO>()
                .eqIfPresent(EvalSubjectDO::getPlanId, reqVO.getPlanId())
                .likeIfPresent(EvalSubjectDO::getSubjectName, reqVO.getSubjectName())
                .eqIfPresent(EvalSubjectDO::getSubjectType, reqVO.getSubjectType())
                .betweenIfPresent(EvalSubjectDO::getExamStartTime, reqVO.getExamStartTime())
                .betweenIfPresent(EvalSubjectDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EvalSubjectDO::getId));
    }

    default List<EvalSubjectDO> selectListByPlanId(Long planId) {
        return selectList(EvalSubjectDO::getPlanId, planId);
    }

    default List<EvalSubjectDO> selectListBySubjectType(String subjectType) {
        return selectList(EvalSubjectDO::getSubjectType, subjectType);
    }

    default List<EvalSubjectDO> selectListByPlanIdAndType(Long planId, String subjectType) {
        return selectList(new LambdaQueryWrapperX<EvalSubjectDO>()
                .eq(EvalSubjectDO::getPlanId, planId)
                .eq(EvalSubjectDO::getSubjectType, subjectType));
    }

}
